﻿using System;
using System.IO;
using System.Windows;


namespace MC.Warehouse
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App
    {
        private void Application_DispatcherUnhandledException(object sender,
                                                              System.Windows.Threading.
                                                                  DispatcherUnhandledExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.StackTrace, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            Log(e.Exception.StackTrace);
            e.Handled = true;
        }

        public static void Log(string message)
        {
            File.AppendAllText(@"..\log.txt",
                               string.Format("[{0}] [{1}] \n\n{2}{3}", DateTime.Now.ToString("F"),
                                             System.Threading.Thread.CurrentThread.ManagedThreadId, message,
                                             Environment.NewLine));
        }
    }
}
